﻿Imports System.Data.SqlClient
Public Class clsEmpleados
    Private mintIdEmpleado As Integer
    Private mintIdDepartamento As Integer
    Private mintIdPuesto As Integer
    Private mintIdPeriodo As Integer
    Private mintIdTurno As Integer
    Private mstrCodigo As String
    Private mstrNombre As String
    Private mstrApellidoPaterno As String
    Private mstrApellidoMaterno As String
    Private mstrNombreCompleto As String
    Private mdatFechaNacimiento As Date
    Private mstrLugarNacimiento As String
    Private mstrEstadoCivil As String
    Private mstrSexo As String
    Private mstrCURP As String
    Private mstrCURPF As String
    Private mstrNSS As String
    Private mstrRFC As String
    Private mstrHomoclave As String
    Private mstrCuentaPago As String
    Private mstrSucursal As String
    Private mstrBancoPago As String
    Private mstrEstadoEmpleado As String
    Private mdblSD As Decimal
    Private mdatFechaSD As Date
    Private mdblSDI As Decimal
    Private mdatFechaSDI As Date
    Private mdatFechaAlta As Date
    Private mstrCuentaCW As String
    Private mstrTelefono As String
    Private mintCodigoPostal As String
    Private mstrDireccion As String
    Private mstrPoblacion As String
    Private mstrEstado As String
    Private mdatFechaBaja As Date
    Private mstrCausaBaja As String
    Private mstrCelular As String
    Private mstrTelefonoRecados As String
    Private mstrEscolaridad As String
    Private mdatFechaReingreso As Date
    Private mdblPorcentajeDescuento As Double
    Private mintDependientes As Integer
    Private mstrReligion As String
    Private mstrUMF As String
    Private mstrCorreoElectronico As String
    Private mstrTipoRegimen As String
    Private mstrClabeInterbancaria As String


    Public Property IDEmpleado() As Integer
        Get
            Return mintIdEmpleado
        End Get
        Set(ByVal value As Integer)
            mintIdEmpleado = value
        End Set
    End Property
    Public Property IdDepartamento() As Integer
        Get
            Return mintIdDepartamento
        End Get
        Set(ByVal value As Integer)
            mintIdDepartamento = value
        End Set
    End Property
    Public Property IDPuesto() As Integer
        Get
            Return mintIdPuesto
        End Get
        Set(ByVal value As Integer)
            mintIdPuesto = value
        End Set
    End Property
    Public Property IDPerdiodo() As Integer
        Get
            Return mintIdPeriodo
        End Get
        Set(ByVal value As Integer)
            mintIdPeriodo = value
        End Set
    End Property
    Public Property IDTurno() As Integer
        Get
            Return mintIdTurno
        End Get
        Set(ByVal value As Integer)
            mintIdTurno = value
        End Set
    End Property

    Public Property Codigo() As String
        Get
            Return mstrCodigo
        End Get
        Set(ByVal value As String)
            mstrCodigo = value
        End Set
    End Property
    Public Property Nombre() As String
        Get
            Return mstrNombre
        End Get
        Set(ByVal value As String)
            mstrNombre = value
        End Set
    End Property
    Public Property ApellidoPaterno() As String
        Get
            Return mstrApellidoPaterno
        End Get
        Set(ByVal value As String)
            mstrApellidoPaterno = value
        End Set
    End Property
    Public Property ApellidoMaterno() As String
        Get
            Return mstrApellidoMaterno
        End Get
        Set(ByVal value As String)
            mstrApellidoMaterno = value
        End Set
    End Property
    Public Property NombreCompleto() As String
        Get
            Return mstrNombreCompleto
        End Get
        Set(ByVal value As String)
            mstrNombreCompleto = value
        End Set
    End Property
    Public Property FechaNacimiento() As Date
        Get
            Return mdatFechaNacimiento
        End Get
        Set(ByVal value As Date)
            mdatFechaNacimiento = value
        End Set
    End Property
    Public Property LugarNacimiento() As String
        Get
            Return mstrLugarNacimiento
        End Get
        Set(ByVal value As String)
            mstrLugarNacimiento = value
        End Set
    End Property
    Public Property EstadoCivil() As String
        Get
            Return mstrEstadoCivil
        End Get
        Set(ByVal value As String)
            mstrEstadoCivil = value
        End Set
    End Property
    Public Property Sexo() As String
        Get
            Return mstrSexo
        End Get
        Set(ByVal value As String)
            mstrSexo = value
        End Set
    End Property
    Public Property CURP() As String
        Get
            Return mstrCURP
        End Get
        Set(ByVal value As String)
            mstrCURP = value
        End Set
    End Property
    Public Property CURPF() As String
        Get
            Return mstrCURPF
        End Get
        Set(ByVal value As String)
            mstrCURPF = value
        End Set
    End Property
    Public Property NSS() As String
        Get
            Return mstrNSS
        End Get
        Set(ByVal value As String)
            mstrNSS = value
        End Set
    End Property
    Public Property RFC() As String
        Get
            Return mstrRFC
        End Get
        Set(ByVal value As String)
            mstrRFC = value
        End Set
    End Property
    Public Property Homoclave() As String
        Get
            Return mstrHomoclave
        End Get
        Set(ByVal value As String)
            mstrHomoclave = value
        End Set
    End Property
    Public Property CuentaPago() As String
        Get
            Return mstrCuentaPago
        End Get
        Set(ByVal value As String)
            mstrCuentaPago = value
        End Set
    End Property
    Public Property Sucursal() As String
        Get
            Return mstrSucursal
        End Get
        Set(ByVal value As String)
            mstrSucursal = value
        End Set
    End Property
    Public Property BancoPago() As String
        Get
            Return mstrBancoPago
        End Get
        Set(ByVal value As String)
            mstrBancoPago = value
        End Set
    End Property
    Public Property EstadoEmpleado() As String
        Get
            Return mstrEstadoEmpleado
        End Get
        Set(ByVal value As String)
            mstrEstadoEmpleado = value
        End Set
    End Property
    Public Property SD() As Decimal
        Get
            Return mdblSD

        End Get
        Set(ByVal value As Decimal)
            mdblSD = value
        End Set
    End Property
    Public Property FechaSD() As Date
        Get
            Return mdatFechaSD
        End Get
        Set(ByVal value As Date)
            mdatFechaSD = value
        End Set
    End Property
    Public Property SDI() As Decimal
        Get
            Return mdblSDI

        End Get
        Set(ByVal value As Decimal)
            mdblSDI = value
        End Set
    End Property
    Public Property FechaSDI() As Date
        Get
            Return mdatFechaSDI
        End Get
        Set(ByVal value As Date)
            mdatFechaSDI = value
        End Set
    End Property
    Public Property FechaAlta() As Date
        Get
            Return mdatFechaAlta
        End Get
        Set(ByVal value As Date)
            mdatFechaAlta = value
        End Set
    End Property
    Public Property CuentaCW() As String
        Get
            Return mstrCuentaCW
        End Get
        Set(ByVal value As String)
            mstrCuentaCW = value
        End Set
    End Property
    Public Property Telefono() As String
        Get
            Return mstrTelefono
        End Get
        Set(ByVal value As String)
            mstrTelefono = value
        End Set
    End Property
    Public Property CodigoPostal() As String
        Get
            Return mintCodigoPostal
        End Get
        Set(ByVal value As String)
            mintCodigoPostal = value
        End Set
    End Property
    Public Property Direccion() As String
        Get
            Return mstrDireccion
        End Get
        Set(ByVal value As String)
            mstrDireccion = value
        End Set
    End Property
    Public Property Poblacion() As String
        Get
            Return mstrPoblacion
        End Get
        Set(ByVal value As String)
            mstrPoblacion = value
        End Set
    End Property
    Public Property Estado() As String
        Get
            Return mstrEstado
        End Get
        Set(ByVal value As String)
            mstrEstado = value
        End Set
    End Property
    Public Property FechaBaja() As Date
        Get
            Return mdatFechaBaja
        End Get
        Set(ByVal value As Date)
            mdatFechaBaja = value
        End Set
    End Property
    Public Property CausaBaja() As String
        Get
            Return mstrCausaBaja
        End Get
        Set(ByVal value As String)
            mstrCausaBaja = value
        End Set
    End Property

    Public Property Celular() As String
        Get
            Return mstrCelular
        End Get
        Set(ByVal value As String)
            mstrCelular = value
        End Set
    End Property
    Public Property TelefonoRecados() As String
        Get
            Return mstrTelefonoRecados
        End Get
        Set(ByVal value As String)
            mstrTelefonoRecados = value
        End Set
    End Property
    Public Property Escolaridad() As String
        Get
            Return mstrEscolaridad
        End Get
        Set(ByVal value As String)
            mstrEscolaridad = value
        End Set
    End Property
    Public Property FechaReingreso() As Date
        Get
            Return mdatFechaReingreso
        End Get
        Set(ByVal value As Date)
            mdatFechaReingreso = value
        End Set
    End Property
    Public Property PorcentajeDescuento() As Double
        Get
            Return mdblPorcentajeDescuento
        End Get
        Set(value As Double)
            mdblPorcentajeDescuento = value
        End Set
    End Property
    Public Property Dependientes() As Integer
        Get
            Return mintDependientes
        End Get
        Set(ByVal value As Integer)
            mintDependientes = value
        End Set
    End Property
    Public Property Religion() As String
        Get
            Return mstrReligion
        End Get
        Set(ByVal value As String)
            mstrReligion = value
        End Set
    End Property
    Public Property UMF() As String
        Get
            Return mstrUMF
        End Get
        Set(ByVal value As String)
            mstrUMF = value
        End Set
    End Property
    Public Property CorreoEelectronico() As String
        Get
            Return mstrCorreoElectronico
        End Get
        Set(ByVal value As String)
            mstrCorreoElectronico = value
        End Set
    End Property
    Public Property TipoRegimen() As String
        Get
            Return mstrTipoRegimen
        End Get
        Set(ByVal value As String)
            mstrTipoRegimen = value
        End Set
    End Property
    Public Property ClabeInterbancaria() As String
        Get
            Return mstrClabeInterbancaria
        End Get
        Set(ByVal value As String)
            mstrClabeInterbancaria = value
        End Set
    End Property
    Public Sub New()
        mintIdEmpleado = 0
        mintIdDepartamento = 0
        mintIdPuesto = 0
        mintIdPeriodo = 0
        mintIdTurno = 0
        mstrCodigo = ""
        mstrNombre = ""
        mstrApellidoPaterno = ""
        mstrApellidoMaterno = ""
        mstrNombreCompleto = ""
        mdatFechaNacimiento = Now()
        mstrLugarNacimiento = ""
        mstrEstadoCivil = ""
        mstrSexo = ""
        mstrCURP = ""
        mstrCURPF = ""
        mstrNSS = ""
        mstrRFC = ""
        mstrHomoclave = ""
        mstrCuentaPago = ""
        mstrSucursal = ""
        mstrBancoPago = 0
        mstrEstadoEmpleado = ""
        mdblSDI = 0
        mdatFechaSDI = Now()
        mdblSDI = 0
        mdatFechaSDI = Now()
        mdatFechaAlta = Now()
        mstrCuentaCW = ""
        mstrTelefono = ""
        mintCodigoPostal = 0
        mstrDireccion = ""
        mstrPoblacion = ""
        mstrEstado = ""
        mdatFechaBaja = Now()
        mstrCausaBaja = ""
        mstrCelular = ""
        mstrTelefonoRecados = ""
        mstrEscolaridad = ""
        mdatFechaReingreso = Now()
        mdblPorcentajeDescuento = 0
        mintDependientes = 0
        mstrReligion = ""
        mstrUMF = ""
        mstrCorreoElectronico = ""
        mstrTipoRegimen = ""
        mstrClabeInterbancaria = ""

    End Sub
    Public Sub Guardar()
        If IDEmpleado = 0 Then
            Exit Sub
        End If

        Dim intRetVal As Integer

        intRetVal = BuscarIntDatoCitra("Empleados", "IDEmpleado", "IDEmpleado =" & IDEmpleado)

        If intRetVal = 0 Then
            Insertar()
        Else
            Actualizar()

        End If

    End Sub
    Public Sub Borrar()
        Call SetSqlCitra("Delete From Empleados Where IDEmpleado = " & IDEmpleado)

    End Sub
    Public Sub Buscar()
        Dim cnConn As New SqlConnection
        cnConn.ConnectionString = CitraConnection

        Dim cmdBuscar As New SqlCommand
        cmdBuscar.Connection = cnConn
        cmdBuscar.CommandText = "SELECT * From Empleados " & _
        " WHERE IDEmpleado=" & IDEmpleado

        Dim rdBuscar As SqlDataReader

        cnConn.Open()
        rdBuscar = cmdBuscar.ExecuteReader

        If rdBuscar.Read() Then
            mintIdEmpleado = rdBuscar("IDEmpleado")
            mintIdDepartamento = rdBuscar("IdDepartamento")
            mintIdPuesto = rdBuscar("IdPuesto")
            mintIdPeriodo = rdBuscar("IDperiodo")
            mintIdTurno = rdBuscar("IdTurno")
            mstrCodigo = rdBuscar("Codigo").ToString.Trim
            mstrNombre = rdBuscar("Nombre").ToString.Trim
            mstrApellidoPaterno = rdBuscar("ApellidoPaterno").ToString.Trim
            mstrApellidoMaterno = rdBuscar("ApellidoMaterno").ToString.Trim
            mstrNombreCompleto = rdBuscar("Nombrecompleto").ToString.Trim
            mdatFechaNacimiento = rdBuscar("FechaNacimiento")
            mstrLugarNacimiento = rdBuscar("LugarNacimiento").ToString.Trim
            mstrEstadoCivil = rdBuscar("EstadoCivil").ToString.Trim
            mstrSexo = rdBuscar("Sexo").ToString.Trim
            mstrCURP = rdBuscar("CURP").ToString.Trim
            mstrCURPF = rdBuscar("CURPF").ToString.Trim
            mstrNSS = rdBuscar("NSS").ToString.Trim
            mstrRFC = rdBuscar("RFC").ToString.Trim
            mstrHomoclave = rdBuscar("Homoclave").ToString.Trim
            mstrCuentaPago = rdBuscar("CuentaPago").ToString.Trim
            mstrSucursal = rdBuscar("Sucursal").ToString.Trim
            mstrBancoPago = rdBuscar("BancoPago")
            mstrEstadoEmpleado = rdBuscar("EstadoEmpleado").ToString.Trim
            mdblSD = rdBuscar("SD")
            mdblSDI = rdBuscar("Sdi")
            mdatFechaSDI = rdBuscar("FechaSdi")
            mdatFechaAlta = rdBuscar("FechaAlta")
            mstrCuentaCW = rdBuscar("CuentaCW").ToString.Trim
            mstrTelefono = rdBuscar("Telefono").ToString.Trim
            mintCodigoPostal = rdBuscar("CodigoPostal")
            mstrDireccion = rdBuscar("Direccion").ToString.Trim
            mstrPoblacion = rdBuscar("Poblacion").ToString.Trim
            mstrEstado = rdBuscar("Estado").ToString.Trim
            Try
                mdatFechaBaja = rdBuscar("FechaBaja")
            Catch ex As Exception
            End Try
            mstrCausaBaja = rdBuscar("CausaBaja").ToString.Trim
            mstrCelular = rdBuscar("Celular").ToString.Trim
            mstrTelefonoRecados = rdBuscar("telefonorecados").ToString.Trim
            mstrEscolaridad = rdBuscar("Escolaridad").ToString.Trim
            Try
                mdatFechaReingreso = rdBuscar("FechaReingreso")
            Catch ex As Exception

            End Try
            mdblPorcentajeDescuento = rdBuscar("porcentajedescuento")
            mintDependientes = rdBuscar("Dependientes")
            mstrReligion = rdBuscar("Religion")
            mstrUMF = rdBuscar("UMF")
            mstrCorreoElectronico = rdBuscar("CorreoElectronico")
            mstrTipoRegimen = rdBuscar("TipoRegimen")
            mstrClabeInterbancaria = rdBuscar("ClabeInterbancaria")
        Else
            mintIdEmpleado = 0
            mintIdDepartamento = 0
            mintIdPuesto = 0
            mintIdPeriodo = 0
            mintIdTurno = 0
            mstrCodigo = ""
            mstrNombre = ""
            mstrApellidoPaterno = ""
            mstrApellidoMaterno = ""
            mstrNombreCompleto = ""
            mdatFechaNacimiento = Now()
            mstrLugarNacimiento = ""
            mstrEstadoCivil = ""
            mstrSexo = ""
            mstrCURP = ""
            mstrCURPF = ""
            mstrNSS = ""
            mstrRFC = ""
            mstrHomoclave = ""
            mstrCuentaPago = ""
            mstrSucursal = ""
            mstrBancoPago = 0
            mstrEstadoEmpleado = ""
            mdblSDI = 0
            mdatFechaSDI = Now()
            mdblSDI = 0
            mdatFechaSDI = Now()
            mdatFechaAlta = Now()
            mstrCuentaCW = ""
            mstrTelefono = ""
            mintCodigoPostal = 0
            mstrDireccion = ""
            mstrPoblacion = ""
            mstrEstado = ""
            mdatFechaBaja = Now()
            mstrCausaBaja = ""
            mstrCelular = ""
            mstrTelefonoRecados = ""
            mstrEscolaridad = ""
            mdatFechaReingreso = Now()
            mdblPorcentajeDescuento = 0
            mintDependientes = 0
            mstrReligion = ""
            mstrUMF = ""
            mstrCorreoElectronico = ""
            mstrTipoRegimen = ""
            mstrClabeInterbancaria = ""
        End If

        rdBuscar.Close()
        cnConn.Close()


    End Sub
    Public Sub Insertar()
        Dim sql As String = "Insert Into Empleados (" & _
                            "IdEmpleado," & _
                            "IdDepartamento," & _
                            "IdPuesto," & _
                            "IdPeriodo," & _
                            "IdTurno," & _
                            "Codigo," & _
                            "Nombre," & _
                            "ApellidoPaterno," & _
                            "ApellidoMaterno," & _
                            "NombreCompleto," & _
                            "FechaNacimiento," & _
                            "LugarNacimiento," & _
                            "EstadoCivil," & _
                            "Sexo," & _
                            "CURP," & _
                            "CURPF," & _
                            "NSS," & _
                            "RFC," & _
                            "Homoclave," & _
                            "CuentaPago," & _
                            "Sucursal," & _
                            "BancoPago," & _
                            "EstadoEmpleado," & _
                            "SD," & _
                            "FechaSD," & _
                            "SDI," & _
                            "FechaSDI," & _
                            "FechaAlta," & _
                            "CuentaCW," & _
                            "Telefono," & _
                            "CodigoPostal," & _
                            "Direccion," & _
                            "Poblacion," & _
                            "Estado," & _
                            "FechaBaja," & _
                            "CausaBaja," & _
                            "Celular," & _
                            "TelefonoRecados," & _
                            "Escolaridad," & _
                            "FechaReingreso," & _
                            "PorcentajeDescuento, " & _
                            "Dependientes," & _
                            "Religion, " & _
                            "UMF, " & _
                            "CorreoElectronico," & _
                            "TipoRegimen," & _
                            "ClabeInterbancaria)" & _
                            "VALUES (" & _
                            "@IdEmpleado," & _
                            "@IdDepartamento," & _
                            "@IdPuesto," & _
                            "@IdPeriodo," & _
                            "@IdTurno," & _
                            "substring(@Codigo,1,50)," & _
                            "substring(@Nombre,1,50)," & _
                            "substring(@ApellidoPaterno,1,50)," & _
                            "substring(@ApellidoMaterno,1,50)," & _
                            "substring(@NombreCompleto,1,150)," & _
                            "@FechaNacimiento," & _
                            "substring(@LugarNacimiento,1,100)," & _
                            "substring(@EstadoCivil,1,1)," & _
                            "substring(@Sexo,1,1)," & _
                            "substring(@CURP,1,4)," & _
                            "substring(@CURPF,1,8)," & _
                            "substring(@NSS,1,20)," & _
                            "substring(@RFC,1,4)," & _
                            "substring(@Homoclave,1,3)," & _
                            "substring(@CuentaPago,1,20)," & _
                            "substring(@Sucursal,1,30)," & _
                            "substring(@BancoPago,1,10)," & _
                            "substring(@EstadoEmpleado,1,1)," & _
                            "@SD," & _
                            "@FechaSD," & _
                            "@SDI," & _
                            "@FechaSDI," & _
                            "@FechaAlta," & _
                            "substring(@CuentaCW,1,15)," & _
                            "substring(@Telefono,1,20)," & _
                            "substring(@CodigoPostal,1,10)," & _
                            "substring(@Direccion,1,200)," & _
                            "substring(@Poblacion,1,50)," & _
                            "substring(@Estado,1,50)," & _
                            "@FechaBaja," & _
                            "substring(@CausaBaja,1,200)," & _
                            "substring(@Celular,1,20)," & _
                            "substring(@TelefonoRecados,1,20)," & _
                            "substring(@Escolaridad,1,100)," & _
                            "@FechaReingreso," & _
                            "@PorcentajeDescuento, " & _
                            "@Dependientes," & _
                            "substring(@Religion,1,200)," & _
                            "substring(@UMF,1,200)," & _
                            "substring(@CorreoElectronico,1,60)," & _
                            "substring(@TipoRegimen,1,25)," & _
                            "substring(@ClabeInterbancaria,1,30))"

        Dim cnConn As New SqlConnection
        cnConn.ConnectionString = CitraConnection

        Dim Command As New SqlCommand(sql, cnConn)

        Command.Parameters.AddWithValue("IdEmpleado", mintIdEmpleado)
        Command.Parameters.AddWithValue("IdDepartamento", mintIdDepartamento)
        Command.Parameters.AddWithValue("IdPuesto", mintIdPuesto)
        Command.Parameters.AddWithValue("IdPeriodo", mintIdPeriodo)
        Command.Parameters.AddWithValue("IdTurno", mintIdTurno)
        Command.Parameters.AddWithValue("Codigo", mstrCodigo)
        Command.Parameters.AddWithValue("Nombre", mstrNombre)
        Command.Parameters.AddWithValue("ApellidoPaterno", mstrApellidoPaterno)
        Command.Parameters.AddWithValue("ApellidoMaterno", mstrApellidoMaterno)
        Command.Parameters.AddWithValue("NombreCompleto", mstrNombreCompleto)
        Command.Parameters.AddWithValue("FechaNacimiento", mdatFechaNacimiento)
        Command.Parameters.AddWithValue("LugarNacimiento", mstrLugarNacimiento)
        Command.Parameters.AddWithValue("EstadoCivil", mstrEstadoCivil)
        Command.Parameters.AddWithValue("Sexo", mstrSexo)
        Command.Parameters.AddWithValue("CURP", mstrCURP)
        Command.Parameters.AddWithValue("CURPF", mstrCURPF)
        Command.Parameters.AddWithValue("NSS", mstrNSS)
        Command.Parameters.AddWithValue("RFC", mstrRFC)
        Command.Parameters.AddWithValue("Homoclave", mstrHomoclave)
        Command.Parameters.AddWithValue("CuentaPago", mstrCuentaPago)
        Command.Parameters.AddWithValue("Sucursal", mstrSucursal)
        Command.Parameters.AddWithValue("BancoPago", mstrBancoPago)
        Command.Parameters.AddWithValue("EstadoEmpleado", mstrEstadoEmpleado)
        Command.Parameters.AddWithValue("SD", mdblSD)
        Command.Parameters.AddWithValue("FechaSD", mdatFechaSD)
        Command.Parameters.AddWithValue("SDI", mdblSDI)
        Command.Parameters.AddWithValue("FechaSDI", mdatFechaSDI)
        Command.Parameters.AddWithValue("FechaAlta", mdatFechaAlta)
        Command.Parameters.AddWithValue("CuentaCW", mstrCuentaCW)
        Command.Parameters.AddWithValue("Telefono", mstrTelefono)
        Command.Parameters.AddWithValue("CodigoPostal", mintCodigoPostal)
        Command.Parameters.AddWithValue("Direccion", mstrDireccion)
        Command.Parameters.AddWithValue("Poblacion", mstrPoblacion)
        Command.Parameters.AddWithValue("Estado", mstrEstado)
        Command.Parameters.AddWithValue("FechaBaja", mdatFechaBaja)
        Command.Parameters.AddWithValue("CausaBaja", mstrCausaBaja)
        Command.Parameters.AddWithValue("Celular", mstrCelular)
        Command.Parameters.AddWithValue("TelefonoRecados", mstrTelefonoRecados)
        Command.Parameters.AddWithValue("Escolaridad", mstrEscolaridad)
        Command.Parameters.AddWithValue("FechaReingreso", mdatFechaReingreso)
        Command.Parameters.AddWithValue("PorcentajeDescuento", mdblPorcentajeDescuento)
        Command.Parameters.AddWithValue("Dependientes", mintDependientes)
        Command.Parameters.AddWithValue("Religion", mstrReligion)
        Command.Parameters.AddWithValue("UMF", mstrUMF)
        Command.Parameters.AddWithValue("CorreoElectronico", mstrCorreoElectronico)
        Command.Parameters.AddWithValue("TipoRegimen", mstrTipoRegimen)
        Command.Parameters.AddWithValue("ClabeInterbancaria", mstrClabeInterbancaria)

        cnConn.Open()
        Dim RowsAffected As Integer
        Try
            RowsAffected = Command.ExecuteNonQuery
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Aviso")
        End Try

        If RowsAffected > 0 Then
            cnConn.Close()
        Else
            MsgBox("No fue posible insertar el Empleado " & mstrNombreCompleto, MsgBoxStyle.Exclamation, "Aviso")
            If cnConn.State = ConnectionState.Open Then
                cnConn.Close()
            End If
        End If
    End Sub
    Sub Actualizar()
        Dim strSqlQry As String
        Dim cnConn As New SqlConnection
        cnConn.ConnectionString = CitraConnection

        strSqlQry = "Update Empleados Set " & _
                            "IdDepartamento=@IdDepartamento," & _
                            "IdPuesto=@IdPuesto," & _
                            "IdPeriodo=IdPeriodo," & _
                            "IdTurno=@IdTurno," & _
                            "Codigo=substring(@Codigo,1,50)," & _
                            "Nombre=substring(@Nombre,1,50)," & _
                            "ApellidoPaterno=substring(@ApellidoPaterno,1,50)," & _
                            "ApellidoMaterno=substring(@ApellidoMaterno,1,50)," & _
                            "NombreCompleto=substring(@NombreCompleto,1,150)," & _
                            "FechaNacimiento=@FechaNacimiento," & _
                            "LugarNacimiento=substring(@LugarNacimiento,1,100)," & _
                            "EstadoCivil=substring(@EstadoCivil,1,1)," & _
                            "Sexo=substring(@Sexo,1,1)," & _
                            "CURP=substring(@CURP,1,4)," & _
                            "CURPF=substring(@CURPF,1,8)," & _
                            "NSS=SUBSTRING(@NSS,1,20)," & _
                            "RFC=substring(@RFC,1,4)," & _
                            "Homoclave=substring(@Homoclave,1,3)," & _
                            "CuentaPago=substring(@CuentaPago,1,20)," & _
                            "Sucursal=substring(@Sucursal,1,30)," & _
                            "BancoPago=substring(@BancoPago,1,10)," & _
                            "EstadoEmpleado=substring(@EstadoEmpleado,1,1)," & _
                            "SD=@SD," & _
                            "FechaSD=@FechaSD," & _
                            "SDI=@SDI," & _
                            "FechaSDI=@FechaSDI," & _
                            "FechaAlta=@FechaAlta," & _
                            "CuentaCW=substring(@CuentaCW,1,15)," & _
                            "Telefono=substring(@Telefono,1,20)," & _
                            "CodigoPostal=substring(@CodigoPostal,1,10)," & _
                            "Direccion=substring(@Direccion,1,200)," & _
                            "Poblacion=substring(@Poblacion,1,50)," & _
                            "Estado=substring(@Estado,1,50)," & _
                            "FechaBaja=@FechaBaja," & _
                            "CausaBaja=substring(@CausaBaja,1,200)," & _
                            "Celular=substring(@Celular,1,20)," & _
                            "TelefonoRecados=substring(@TelefonoRecados,1,20)," & _
                            "Escolaridad=substring(@Escolaridad,1,100)," & _
                            "FechaReingreso=@FechaReingreso," & _
                            "PorcentajeDescuento=@PorcentajeDescuento, " & _
                            "Dependientes=@Dependientes," & _
                            "Religion=substring(@Religion,1,200), " & _
                            "UMF=substring(@UMF,1,200), " & _
                            "CorreoElectronico=substring(@CorreoElectronico,1,60), " & _
                            "TipoRegimen=substring(@TipoRegimen,1,25), " & _
                            "ClabeInterbancaria=substring(@ClabeInterbancaria,1,30) " & _
                            " WHERE IdEmpleado=@IdEmpleado"

        Dim Command As New SqlCommand(strSqlQry, cnConn)
        Command.Parameters.AddWithValue("IdEmpleado", mintIdEmpleado)
        Command.Parameters.AddWithValue("IdDepartamento", mintIdDepartamento)
        Command.Parameters.AddWithValue("IdPuesto", mintIdPuesto)
        Command.Parameters.AddWithValue("IdPeriodo", mintIdPeriodo)
        Command.Parameters.AddWithValue("IdTurno", mintIdTurno)
        Command.Parameters.AddWithValue("Codigo", mstrCodigo)
        Command.Parameters.AddWithValue("Nombre", mstrNombre)
        Command.Parameters.AddWithValue("ApellidoPaterno", mstrApellidoPaterno)
        Command.Parameters.AddWithValue("ApellidoMaterno", mstrApellidoMaterno)
        Command.Parameters.AddWithValue("NombreCompleto", mstrNombreCompleto)
        Command.Parameters.AddWithValue("FechaNacimiento", mdatFechaNacimiento)
        Command.Parameters.AddWithValue("LugarNacimiento", mstrLugarNacimiento)
        Command.Parameters.AddWithValue("EstadoCivil", mstrEstadoCivil)
        Command.Parameters.AddWithValue("Sexo", mstrSexo)
        Command.Parameters.AddWithValue("CURP", mstrCURP)
        Command.Parameters.AddWithValue("CURPF", mstrCURPF)
        Command.Parameters.AddWithValue("NSS", mstrNSS)
        Command.Parameters.AddWithValue("RFC", mstrRFC)
        Command.Parameters.AddWithValue("Homoclave", mstrHomoclave)
        Command.Parameters.AddWithValue("CuentaPago", mstrCuentaPago)
        Command.Parameters.AddWithValue("Sucursal", mstrSucursal)
        Command.Parameters.AddWithValue("BancoPago", mstrBancoPago)
        Command.Parameters.AddWithValue("EstadoEmpleado", mstrEstadoEmpleado)
        Command.Parameters.AddWithValue("SD", mdblSD)
        Command.Parameters.AddWithValue("FechaSD", mdatFechaSD)
        Command.Parameters.AddWithValue("SDI", mdblSDI)
        Command.Parameters.AddWithValue("FechaSDI", mdatFechaSDI)
        Command.Parameters.AddWithValue("FechaAlta", mdatFechaAlta)
        Command.Parameters.AddWithValue("CuentaCW", mstrCuentaCW)
        Command.Parameters.AddWithValue("Telefono", mstrTelefono)
        Command.Parameters.AddWithValue("CodigoPostal", mintCodigoPostal)
        Command.Parameters.AddWithValue("Direccion", mstrDireccion)
        Command.Parameters.AddWithValue("Poblacion", mstrPoblacion)
        Command.Parameters.AddWithValue("Estado", mstrEstado)
        Command.Parameters.AddWithValue("FechaBaja", mdatFechaBaja)
        Command.Parameters.AddWithValue("CausaBaja", mstrCausaBaja)
        Command.Parameters.AddWithValue("Celular", mstrCelular)
        Command.Parameters.AddWithValue("TelefonoRecados", mstrTelefonoRecados)
        Command.Parameters.AddWithValue("Escolaridad", mstrEscolaridad)
        Command.Parameters.AddWithValue("FechaReingreso", mdatFechaReingreso)
        Command.Parameters.AddWithValue("PorcentajeDescuento", mdblPorcentajeDescuento)
        Command.Parameters.AddWithValue("Dependientes", mintDependientes)
        Command.Parameters.AddWithValue("Religion", mstrReligion)
        Command.Parameters.AddWithValue("UMF", mstrUMF)
        Command.Parameters.AddWithValue("CorreoElectronico", mstrCorreoElectronico)
        Command.Parameters.AddWithValue("TipoRegimen", mstrTipoRegimen)
        Command.Parameters.AddWithValue("ClabeInterbancaria", mstrClabeInterbancaria)

        cnConn.Open()

        Dim RowsAffected As Integer = Command.ExecuteNonQuery

        If RowsAffected > 0 Then
            cnConn.Close()
        Else
            MsgBox("No fue posible actualizar el registro", MsgBoxStyle.Exclamation, "Aviso")
            If cnConn.State = ConnectionState.Open Then
                cnConn.Close()
            End If
        End If



    End Sub
    Sub ActualizarBaja()
        Dim strSqlQry As String
        Dim cnConn As New SqlConnection
        cnConn.ConnectionString = CitraConnection

        strSqlQry = "Update Empleados Set " & _
                            "EstadoEmpleado=substring(@EstadoEmpleado,1,1)," & _
                            "FechaBaja=@FechaBaja," & _
                            "CausaBaja=substring(@CausaBaja,1,200) " & _
                            " where IdEmpleado=@IdEmpleado"


        Dim Command As New SqlCommand(strSqlQry, cnConn)
        Command.Parameters.AddWithValue("IdEmpleado", mintIdEmpleado)
        Command.Parameters.AddWithValue("EstadoEmpleado", mstrEstadoEmpleado)
        Command.Parameters.AddWithValue("FechaBaja", mdatFechaBaja)
        Command.Parameters.AddWithValue("CausaBaja", mstrCausaBaja)
        
        cnConn.Open()

        Dim RowsAffected As Integer = Command.ExecuteNonQuery

        If RowsAffected > 0 Then
            cnConn.Close()
        Else
            MsgBox("No fue posible actualizar la baja", MsgBoxStyle.Exclamation, "Aviso")
            If cnConn.State = ConnectionState.Open Then
                cnConn.Close()
            End If
        End If



    End Sub
    Sub ActualizarNomiPAQ()
        Dim strSqlQry As String
        Dim cnConn As New SqlConnection
        cnConn.ConnectionString = NominasConnection

        strSqlQry = "Update NOM10001 Set " & _
                    " IdDepartamento=@IdDepartamento," & _
                    " IdPuesto=@IdPuesto," & _
                    " FechaNacimiento=@FechaNacimiento, " & _
                    " LugarNacimiento=substring(@LugarNacimiento,1,40), " & _
                    " EstadoCivil=substring(@EstadoCivil,1,1), " & _
                    " Sexo=substring(@Sexo,1,1), " & _
                    " CURPI=substring(@CURPI,1,6), " & _
                    " CURPF=substring(@CURPF,1,8), " & _
                    " NumeroSeguroSocial=substring(@NumeroSeguroSocial,1,11), " & _
                    " RFC=substring(@RFC,1,4), " & _
                    " Homoclave=substring(@Homoclave,1,4), " & _
                    " CuentaPagoElectronico=substring(@CuentaPagoElectronico,1,20), " & _
                    " CuentaCW=substring(@CuentaCW,1,31)," & _
                    " Telefono=substring(@Telefono,1,20)," & _
                    " CodigoPostal=@CodigoPostal," & _
                    " Direccion=substring(@Direccion,1,60)," & _
                    " Poblacion=substring(@Poblacion,1,60)," & _
                    " Estado=substring(@Estado,1,20)," & _
                    " CampoExtra1=substring(@CampoExtra1,1,40)," & _
                    " CampoExtra2=substring(@CampoExtra2,1,40), " & _
                    " CampoExtra3=substring(@CampoExtra3,1,40),  " & _
                    "CorreoElectronico=substring(@CorreoElectronico,1,60), " & _
                    "TipoRegimen=substring(@TipoRegimen,1,25), " & _
                    "ClabeInterbancaria=substring(@ClabeInterbancaria,1,30) " & _
                    " where CodigoEmpleado=@CodigoEmpleado"


        Dim Command As New SqlCommand(strSqlQry, cnConn)
        Command.Parameters.AddWithValue("IdDepartamento", mintIdDepartamento)
        Command.Parameters.AddWithValue("IdPuesto", mintIdPuesto)
        Command.Parameters.AddWithValue("FechaNacimiento", CDate(mdatFechaNacimiento))
        Command.Parameters.AddWithValue("LugarNacimiento", mstrLugarNacimiento)
        Command.Parameters.AddWithValue("EstadoCivil", mstrEstadoCivil)
        Command.Parameters.AddWithValue("Sexo", mstrSexo)
        Command.Parameters.AddWithValue("CURPI", mstrCURP)
        Command.Parameters.AddWithValue("CURPF", mstrCURPF)
        Command.Parameters.AddWithValue("NumeroSeguroSocial", mstrNSS)
        Command.Parameters.AddWithValue("RFC", mstrRFC)
        Command.Parameters.AddWithValue("Homoclave", mstrHomoclave)
        Command.Parameters.AddWithValue("CuentaPagoElectronico", mstrCuentaPago)
        Command.Parameters.AddWithValue("CuentaCW", mstrCuentaCW)
        Command.Parameters.AddWithValue("Telefono", mstrTelefono)
        Command.Parameters.AddWithValue("CodigoPostal", mintCodigoPostal)
        Command.Parameters.AddWithValue("Direccion", mstrDireccion)
        Command.Parameters.AddWithValue("Poblacion", mstrPoblacion)
        Command.Parameters.AddWithValue("Estado", mstrEstado)
        Command.Parameters.AddWithValue("CampoExtra1", mstrCelular)
        Command.Parameters.AddWithValue("CampoExtra2", mstrTelefonoRecados)
        Command.Parameters.AddWithValue("CampoExtra3", mstrEscolaridad)
        Command.Parameters.AddWithValue("CodigoEmpleado", mstrCodigo)
        Command.Parameters.AddWithValue("CorreoElectronico", mstrCorreoElectronico)
        Command.Parameters.AddWithValue("TipoRegimen", mstrTipoRegimen)
        Command.Parameters.AddWithValue("ClabeInterbancaria", mstrClabeInterbancaria)

        cnConn.Open()

        Dim RowsAffected As Integer = Command.ExecuteNonQuery

        If RowsAffected > 0 Then
            cnConn.Close()
        Else
            MsgBox("No fue posible actualizar los datos en ContPAQ I Nominas", MsgBoxStyle.Exclamation, "Aviso")
            If cnConn.State = ConnectionState.Open Then
                cnConn.Close()
            End If
        End If



    End Sub
    Sub ActualizarNomiPAQEmergente()
        Dim strSqlQry As String
        Dim cnConn As New SqlConnection
        cnConn.ConnectionString = NominasConnection

        strSqlQry = "Update NOM10001 Set " & _
                    " IdDepartamento=@IdDepartamento " & _
                    " where CodigoEmpleado=@CodigoEmpleado"


        Dim Command As New SqlCommand(strSqlQry, cnConn)
        Command.Parameters.AddWithValue("IdDepartamento", mintIdDepartamento)
        Command.Parameters.AddWithValue("IdPeriodo", mintIdPuesto)
        Command.Parameters.AddWithValue("CodigoEmpleado", mstrCodigo)

        cnConn.Open()

        Dim RowsAffected As Integer = Command.ExecuteNonQuery

        If RowsAffected > 0 Then
            cnConn.Close()
        Else
            MsgBox("No fue posible actualizar los datos en ContPAQ I Nominas", MsgBoxStyle.Exclamation, "Aviso")
            If cnConn.State = ConnectionState.Open Then
                cnConn.Close()
            End If
        End If



    End Sub
End Class
